﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BugsData;
using LogicServer;
using CommonCs;
using System.Data;

namespace LogicServer.Bugs
{
    public class BugLogic
    {
        /// <summary>
        /// 根据type获取buglist---ASPNET.Pager分页控件
        /// </summary>
        /// <param name="size">每页多少条数据</param>
        /// <param name="index">当前页索引</param>
        /// <param name="id">bug类型</param>
        /// <returns></returns>
        public DataTable GetListByType(int size, int index, int id) 
        {
            DataTable dt = new DataTable();
            BugData bd = new BugData();
            dt = bd.GetAllBugsByType(size, index, id);
            if (dt == null || dt.Rows.Count == 0)
            {
                return null;
            }
            return dt;
        }
        
        /// <summary>
        /// 根据type获取buglist---Ajax.Pager分页控件
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public DataTable GetBugsByType(int type)
        {
            DataTable dt = new DataTable();
            BugData bd = new BugData();
            dt = bd.GetBugsByType(type);
            if (dt == null || dt.Rows.Count == 0)
            {
                return null;
            }
            return dt;
        }

        /// <summary>
        /// 分页控件获取数据源
        /// </summary>
        /// <param name="index">下标</param>
        /// <param name="size">大小</param>
        /// <returns></returns>
        public DataTable GetBugsByIndex(int index ,int size,int type)
        {
            DataTable dt = new DataTable();
            BugData bd = new BugData();
            dt = bd.AjaxPageByIndex(index, size, type);
            if (dt == null || dt.Rows.Count == 0)
            {
                return null;
            }
            return dt;
        }

        /// <summary>
        /// 根据bugid获取bug信息
        /// </summary>
        /// <param name="id">bugid</param>
        /// <returns>Model.BugUser</returns>
        public Model.BugUser GetBugById(int id)
        {
            Model.BugUser bu = new Model.BugUser();
            BugData bd = new BugData();
            bu = bd.GetBugByBugId(id);
            return bu;
        }

        /// <summary>
        /// 根据title查询buglist
        /// </summary>
        /// <param name="title"></param>
        /// <returns></returns>
        public DataTable SearchBugList(string title)
        {
            BugData bd = new BugData();
            return bd.GetBugListByTitle(title);
        }

        public bool DeleteBug(int id)
        {
            BugData bd = new BugData();
            return false;
        }
    }
}
